package org.example.j1110nm2;

import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("/request")
public class Test02 {
    @RequestMapping("/getCookie")
    public String getCookie(HttpServletRequest request){
        Cookie[] cookies = request.getCookies();

//        Arrays.stream(cookies).forEach(x->{
//            System.out.println(x.getName()+":"+x.getValue());
//        });

        if(cookies != null){
            for(Cookie c:cookies){
                System.out.println(c.getName()+":"+c.getValue());
            }
            return "获取cookie成功";
        }
        return "cookie是空的";
    }
}
